<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="plugins/axios/axios.min.js"></script>
    <script src="plugins/vue/vue.js"></script>
    <script src="plugins/util.js"></script>
</head>
<body>
<div id="app">
    <table border="1">
        <tr>
            <td>
                <input type="hidden" name="id">
                userid
                <select v-model="order.userId">
                    <option v-for="u in user" :value="u.id">
                        {{u.id}} {{u.username}}
                    </option>
            </select>
            </td>
            <td>名称<input type="text" v-model="order.name"></td>
            <td>价格<input type="text" v-model="order.price"></td>
            <td>数量<input type="text" v-model="order.num"></td>
            <td><button @click="edit()" type="button">修改</button></td>

        </tr>
    </table>

    <script>
        new Vue({
            el:"#app",
            data:{
                order:{},
                user:[]
            },
            created(){
                this.hx();
                this.userr();
            },
            methods:{
                edit(){
                    axios.post("/order/edit",this.order).then(res=>{
                        alert("修改成功");
                        location.href="index.html"
                    })
                },
                hx(){
                    var id = getQueryString("id")
                   axios.get("/order/hx?id="+id,this.order).then(res=>{
                       this.order=res.data
                   })
                },
                userr(){
                    axios.get("/order/alll").then(res=>{
                        this.user =res.data
                    })
                }

            }

        })
    </script>
</div>
</body>
</html>